# this is a sample python app that gets data from a twitter tag
# install the simplejson package using easy_install like so: easy_install simplejson
import httplib, sys, simplejson as json
conn = httplib.HTTPConnection("search.twitter.com")
url = "/search.json?q=%23"
tag = "dev8d"
if (len(sys.argv) <= 1):
  print "You must provide the tag to pull data from (without the #), e.g. ", tag
  sys.exit()
else:
  tag = sys.argv[1]
print "Request to:", url+tag
conn.request("GET", url+tag)
res = conn.getresponse()
print "Status:", res.status, res.reason
data = res.read()
# parse the results
jsonLoad = json.loads(data)
stuffs = jsonLoad["results"]
for stuff in stuffs:
  print stuff["text"],"from:",stuff["from_user"]
conn.close()
